//配置路由的地方
import Vue from "vue";
// 引入路由组件
import VueRouter from "vue-router";
// 使用路由插件
Vue.use(VueRouter);
// 引入路由组件
import MyLogin from "@/views/MyLogin/index";
import MyIndex from "@/views/MyIndex/index";
// import MyCenter from "@/views/MyCenter/index";
import MyClub from "@/views/MyClub/index";
import MyMember from "@/views/MyMember/index";
import MyNotice from "@/views/MyNotice/index";
import AdviceList from "@/views/AdviceList/index";
import JoinClub from "@/views/JoinClub/index";
import MyAct from "@/views/MyAct/index";

//保存VueRouter.prototype.push
let originPush = VueRouter.prototype.push;
let originReplace = VueRouter.prototype.replace;

// 重写push和replace
VueRouter.prototype.push = function (location, resolve, reject) {
  if (resolve && reject) {
    originPush.call(this, location, resolve, reject);
  } else {
    originPush.call(
      this,
      location,
      () => {},
      () => {}
    );
  }
};
VueRouter.prototype.replace = function (location, resole, reject) {
  if (resole && reject) {
    originReplace.call(this, location, resole, reject);
  } else {
    originReplace.call(
      this,
      location,
      () => {},
      () => {}
    );
  }
};
//创建并暴露
export default new VueRouter({
  mode: "history",
  routes: [
    {
      path: "/MyLogin",
      name: "MyLogin",
      component: MyLogin,
    },
    {
      path: "/MyIndex",
      name: "MyIndex",
      component: MyIndex,
      children: [
        // {
        //   path: "/MyCenter",
        //   name: "MyCenter",
        //   component: MyCenter,
        // },
        {
          path: "/MyClub",
          name: "MyClub",
          component: MyClub,
        },
        {
          path: "/MyMember",
          name: "MyMember",
          component: MyMember,
        },
        {
          path: "/MyNotice",
          name: "MyNotice",
          component: MyNotice,
          
        },
        {
          path: "/MyAct",
          name: "MyAct",
          component: MyAct,
        },
        {
          path: "/AdviceList",
          name: "AdviceList",
          component: AdviceList,
        },
        {
          path: "/JoinClub",
          name: "JoinClub",
          component: JoinClub,
        },
        
        {
          path: "/",
          redirect: "/MyClub",
        },
      ],
    },
    {
      path: "/",
      redirect: "/MyLogin",
    },
  ],
});
